<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教练员的查看页面</title>
    <link rel="stylesheet" href="../../res/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script src="../../res/js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../res/layui/layui.js"></script>
    <script src="../../res/js/Tools.js"></script>
    <script>
        $.ajaxSetup({
            async : false
        });
    </script>
</head>
<body>
<form class="layui-form" action="" id="Leader">
    <input type="hidden" name="coachId" id="coachIds"/>
    <div class="layui-form-item"></div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">教练员姓名</label>
            <div class="layui-input-block">
                <input disabled="disabled" class="layui-input" type="text" name="coachName" id="coachNames" required
                       lay-verify="required" placeholder="部门名称" autocomplete="off" maxlength="128"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">部门名称</label>
            <div class="layui-input-block">
                <input disabled="disabled" class="layui-input" type="text" name="deptName" id="deptNames" required
                       lay-verify="required" placeholder="部门名称" autocomplete="off" maxlength="128"/>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">岗位名称</label>
            <div class="layui-input-block">
                <input disabled="disabled" class="layui-input" type="text" name="postName" id="postNames" required
                       lay-verify="required" placeholder="岗位名称" autocomplete="off" maxlength="128"/>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">所在单位</label>
            <div class="layui-input-block">
                <input disabled="disabled" class="layui-input" type="text" name="organName" id="organNames" required
                       lay-verify="required" placeholder="所在单位" autocomplete="off" maxlength="128"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">联系方式</label>
            <div class="layui-input-block">
                <input disabled="disabled" class="layui-input" type="text" name="phone" id="phones" required
                       lay-verify="required" placeholder="联系方式" autocomplete="off" maxlength="128"/>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">教练员特点</label>
            <div class="layui-input-block">
                <input disabled="disabled" class="layui-input" type="text" name="coachExp" id="coachExps" required
                       lay-verify="required" placeholder="教练员特点" autocomplete="off" maxlength="128"/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">专业</label>
            <div class="layui-input-inline">
                <select disabled="disabled" name="expertSpecia" id="expertSpecias" lay-filter="aihao" lay-verify="required">
                    <option value=""></option>
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">通讯地址</label>
        <div class="layui-input-block">
            <textarea disabled="disabled" placeholder="请输入内容" class="layui-textarea" name="addr" id="addrs" maxlength="128"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">其他说明</label>
        <div class="layui-input-block">
            <textarea disabled="disabled" placeholder="请输入内容" class="layui-textarea" name="other" id="others" maxlength="128"></textarea>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        //日期渲染
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });
        /**
         * 新增和修改
         */
        var form = null ;
        layui.use('form', function(){
            form = layui.form;
            //训练项目
            $.ajax({
                type:"POST",
                url:'../../UserseControllerCoach/findAllSportName',  //从数据库查询返回的是个list
                dataType: "json",
                contentType: false,
                async: false,
                cache: false,
                success: function (data) {
                    $.each(data,function(index,item){
                        /*$('#sprotNames').append(new Option(item.sportName, item.sportId));*///往下拉菜单里添加元素
                        //$('#expertSpecias').append(new Option(item.sportName));
                        $('#expertSpecias' ). append("<option value='"+item.sportId+"'>"+item.sportName+"</option>")
                    })
                    form.render();//菜单渲染 把内容加载进去
                }
            })
            var id = getQueryString("id");
            if(id !="" && id != null){
                findlx(id);
            }
        });
        /**
         * 修改显示
         */
        function findlx(){
            var id = getQueryString("id");
            //alert(id);
            if(id){
                var url = "../../UserseControllerCoach/findById";
                var data = {coachId:id};
                //jquery的ajax方法,查询类型的方法

                $.get(url,data,function(obj){
                    //从后台传过来的数据obj$("[value='11']").prop("checked",true);
                    $("#coachIds").val(obj.coachId);
                    $("#coachNames").val(obj.coachName);
                    $("#deptNames").val(obj.deptName);
                    $("#postNames").val(obj.postName);
                    $("#organNames").val(obj.organName);
                    //$("#coachExps").val(obj.coachExp);
                    $("#coachExps").val(obj.coachExp);
                    $("#expertSpecias").val(obj.expertSpecia);
                    $("#phones").val(obj.phone);
                    $("#addrs").val(obj.addr);
                    $("#others").val(obj.other);
                    //重新渲染
                    form.render();
                },"json");
            }
        }
    });
</script>
</body>
</html>